package com.juneng.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.R;
import com.juneng.dto.SmsBannerBookDto;
import com.juneng.entity.SmsBannerBook;

import java.util.HashMap;
import java.util.List;
import com.juneng.service.IBookDiscountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.juneng.dto.BookMsgDto;
import com.juneng.dto.BookMsgQueryDto;
import com.juneng.vo.BookMsgVo;
import com.juneng.service.IBookMsgService;

/**
 * 控制器
 * @author zds
 * @since 2021-07-13
 */
@RestController
@AllArgsConstructor
@RequestMapping("bookMsg/v1")
@Api(tags = "相关接口")
public class BookMsgController {

    private IBookMsgService bookMsgService;

    private IBookDiscountService iBookDiscountService;

    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入id")
    public R<BookMsgVo> detail(Long id) {
        BookMsgVo detail = bookMsgService.getById(id);
        return R.success(detail);
    }

    /**
     * 分页
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页", notes = "传入bookMsg")
    public R<IPage<BookMsgVo>> page(BookMsgQueryDto dto) {
        IPage<BookMsgVo> pages = bookMsgService.page(dto);
        return R.success(pages);
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "不分页", notes = "传入bookMsg")
    public R<List<BookMsgVo>> list(BookMsgQueryDto dto) {
        List<BookMsgVo> list = bookMsgService.list(dto);
        return R.success(list);
    }

    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入bookMsg")
    public R save(@RequestBody BookMsgDto dto) {
        return R.success(bookMsgService.save(dto));
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation(value = "修改", notes = "传入bookMsg")
    public R update(@RequestBody BookMsgDto dto) {
        return R.success(bookMsgService.updateById(dto));
    }

    /**
     * 删除  community 课程 appellation
     */
    @DeleteMapping("/remove")
    @ApiOperation(value = "逻辑删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam Long ids) {
        return R.success(bookMsgService.deleteLogic(ids));
    }

    /**
     * 书籍轮播图列表
     */
    @GetMapping("/bannerBookList")
    @ApiOperation(value = "不分页", notes = "传入bookMsg")
    public R<HashMap<String, Object>> bannerBookList(BookMsgQueryDto dto) {
        HashMap<String, Object> list = bookMsgService.bannerBookList(dto);
        return R.success(list);
    }

    /**
     * 新增
     */
    @PostMapping("/bannerBookSave")
    @ApiOperation(value = "新增", notes = "传入bookMsg")
    public R save(@RequestBody SmsBannerBookDto dto) {
        return R.success(bookMsgService.bannerBookSave(dto));
    }

}
